New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ethers-eip712

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethers-eip712

Ethereum Typed Data Hashing and Signing (EIP712) implementation for ethers.js

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-12.84%
Maintainers
1
Weekly downloads
 
Created
Source

ethers-eip712

ethers-eip712 is an npm package that implements the Ethereum Typed Data (EIP712) for structured data hashing and signing proposal, written in TypeScript for ethers.js.

EIP712: https://eips.ethereum.org/EIPS/eip-712

Usage

yarn install ethers-eip712 or npm install ethers-eip712

NOTE: both ethers v4 and ethers v5 are compatible by this single library.

Example

import { ethers } from 'ethers'
import { TypedDataUtils } from 'ethers-eip712'

const typedData = {
  types: {
    EIP712Domain: [
      {name: "name", type: "string"},
      {name: "version", type: "string"},
      {name: "chainId", type: "uint256"},
      {name: "verifyingContract", type: "address"},
    ],
    Person: [
      {name: "name", type: "string"},
      {name: "wallet", type: "address"},  
    ]
  },
  primaryType: 'Person' as const,
  domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
  },
  message: {
    'name': 'Bob',
    'wallet': '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
  }
}

const digest = TypedDataUtils.encodeDigest(typedData)
const digestHex = ethers.utils.hexlify(digest)

const wallet = ethers.Wallet.createRandom()
const signature = wallet.signMessage(digest)

See tests for more examples

License

MIT

FAQs

Package last updated on 10 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc